﻿using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Uipath_License.Uc
{
    /// <summary>
    /// UC_Shortcut.xaml 的交互逻辑
    /// </summary>
    public partial class UC_Shortcut : UserControl
    {
        List<Button> Shortcut_ListBox_Content = new List<Button>();
        public UC_Shortcut()
        {
            InitializeComponent();
            LoadShortcut();
        }

        public void LoadShortcut()
        {
            //Shortcut_ListBox_Content.Add(new Image()
            //{
            //    Source = new BitmapImage(new Uri(System.Environment.CurrentDirectory + "\\Image\\Shortcut\\icon_辅助工具-面 (1).png")),
            //    Width = 50,
            //    Height = 50,
            //    Margin = new Thickness(5)
            //}) ;
            Shortcut_ListBox_Content.Add(GetButton("用户界面探测器", "\\Image\\Shortcut\\icon_辅助工具-面 (1).png"));
            //Shortcut_ListBox.ItemsSource = Shortcut_ListBox_Content;
            foreach (var item in Shortcut_ListBox_Content)
            {
                item.MouseLeftButtonUp += UC_Shortcut_MouseLeftButtonUp;
            }

        }

        public Button GetButton(string name,string url) 
        {
            //<Button x:Name="Get_License_Button" Style="{StaticResource ButtonPrimary}" Click="Get_License_Button_Click" Grid.Row="1">获取License</Button>
            //< WrapPanel >
            //    < Image  RenderOptions.BitmapScalingMode = "HighQuality" Source = "/Image/核查、详细.png" />
            //    < TextBlock > 信息 </ TextBlock >
            //</ WrapPanel >
            Image image = new Image();
            image.Margin = new Thickness(1.5);
            image.Source = new BitmapImage(new Uri(System.Environment.CurrentDirectory + url));
            TextBlock textBlock = new TextBlock();
            textBlock.Text = name;
            textBlock.Margin = new Thickness(1.5);
            WrapPanel wrapPanel = new WrapPanel();
            wrapPanel.Children.Add(image);
            wrapPanel.Children.Add(textBlock);
            Button button = new Button();
            button.Style = License_Message_Button.Style;
            button.Content = wrapPanel;
            return button;
        }

        private void UC_Shortcut_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            System.Windows.MessageBox.Show("test");
        }
    }
}

